package cn.lic.tool.poi.excel;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

import cn.lic.tool.poi.excel.ExcelTemplateParser;
import cn.lic.tool.poi.excel.entry.Order;

public class Excel {

	public static void main(String[] args) throws Exception {
		JSONObject params = new JSONObject();
		params.put("title", "hello poi");
		params.put("orderList", listOrders());
		
		long start = System.currentTimeMillis();
		ExcelTemplateParser excel = new ExcelTemplateParser(params, new File("src/test/java/template.xls")); 
		long end = System.currentTimeMillis();
		System.out.println("用时： " + (end - start));
		excel.write(new File("D:\\test\\template-out.xls"));
		
		
	}

	public static List<Order> listOrders() {
		List<Order> orders = new ArrayList<Order>();
		orders.add(new Order("L001", "广州", 3));
		orders.add(new Order("L002", "广州", 2));
		orders.add(new Order("L003", "广州", 4));
		orders.add(new Order("L004", "深圳", 5));
		orders.add(new Order("L005", "深圳", 6));
		orders.add(new Order("L006", "东莞", 1));
		orders.add(new Order("L007", "珠海", 7));
		orders.add(new Order("L008", "珠海", 8.12346));
		orders.add(new Order("L009", "珠海", 11));
		
//		for (int i = 100; i < 60000; i++) {
//			orders.add(new Order("L" + i, "珠海", 11));
//		}
		
		return orders;
	}
}
